/*
    XTU OJ: 1464
    by: fifth_light
*/

#include <stdio.h>

int main(void) {
    int t;
    scanf("%d ", &t);
    for(int i = 0; i < t; i++) {
        int n, k, c, full = 0, pos = 0, combo = 0, combo2 = 0, half = 0;
        scanf("%d%d ", &n, &k);
        char not_full[10010];
        for (int j = 0; j < n; j++) {
            c = getchar();
            if (c == '0') {
                not_full[pos++] = c;
                combo = 0;
                combo2 = 1;
            } else if (c == '1') {
                not_full[pos++] = c;
                combo++;
                combo2++;
                if (combo == k) {
                    pos -= k;
                    not_full[pos++] = 'x';
                    full++;
                    combo = 0;
                }
                if (combo2 == k * 2) {
                    half = 1;
                }
            }
        }
        not_full[pos] = '\0';
        // puts(not_full);
        if (half == 0)
        for (int j = 0; j < pos - k + 1; j++) {
            int zeros = 0;
            for (int q = 0; q < k; q++) {
                if (not_full[j + q] == '0') {
                    if (zeros == 0) {
                        zeros = 1;
                    } else {
                        goto cont;
                    }
                } else if (not_full[j + q] == 'x') {
                    goto cont;
                }
            }
            half = 1;
            break;
            cont:;
        }
        printf("%d\n", full + half);
        if (i != t - 1) {
            scanf(" ");
        }
    }
    return 0;
}
